package com.store.controller;


import com.store.configure.Result;
import com.store.entity.User;
import com.store.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 登录
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    LoginService loginService;

    /**
     * 登录
     */
    @RequestMapping("/login")
    public Result<User> login(@RequestBody User user, HttpServletRequest request) {
        return loginService.login(user, request);
    }

    /**
     * 登出
     */
    @RequestMapping("/logout")
    public Result<User> logout(HttpServletRequest request) {
        return loginService.logout(request);
    }
}

